package main

import "fmt"

/*
	lesson9: 范围
*/

func main() {
	nums := []int{2, 3, 4}
	dimen := [][]int{{1, 2}, {3, 4}, {5, 6}}
	sum := 0
	// 第一个值为下角标，不需要时使用"_"忽略
	for _, num := range nums {
		sum += num
	}
	fmt.Println("合计:", sum)

	for i, num := range nums {
		if num == 3 {
			fmt.Println("下角标:", i)
		}
	}

	kvs := map[string]string{"a": "apple", "b": "banana"}
	for k, v := range kvs {
		fmt.Printf("%s -> %s\n", k, v)
	}

	for i, c := range "go" {
		fmt.Println(i, c)
	}

	for _, v := range dimen {
		for _, v1 := range v {
			fmt.Println(v1)
		}
	}
}
